home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / ZIPPED / LISTINGS / V_12_11.ZIP / ALLISON.ZIP / STR2.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-06  |  400 b   |  22 lines

  1. LISTING 5 - Adds implementation of assignment operator to the
  2. string class
  3. // str2.cpp
  4. #include <iostream.h>
  5. #include <iomanip.h>
  6. #include <string.h>
  7. #include <assert.h>
  8. #include "str2.h"
  9.  
  10. // Add this:
  11. string& string::operator=(const string& s2)
  12. {
  13.     if (this != &s2)
  14.     {
  15.         delete [] data;
  16.         clone(s2.data);
  17.     }
  18.     return *this;
  19. }
  20.  
  21. // The rest as in Listing 2
  22.